package com.kin207.netty.handle.impl;

import com.kin207.netty.context.RequestContext;
import com.kin207.netty.handle.IMessageHandle;
import com.kin207.netty.msg.vo.SetNameReqVo;

public class SetNameMessageHandle implements IMessageHandle<SetNameReqVo> {

	public String name() {
		return "/name/set";
	}

	public Class paramClass() {
		return SetNameReqVo.class;
	}

	public void handle(SetNameReqVo param) {
		RequestContext req = RequestContext.curr.get();
		String name = param.getName();
		if(name==null || "".equals(name)){
			RequestContext.curr.get().wirte("error:名字不能为空");
		}
		if(!req.getSessionManager().addName(name, req.getChannelHandlerContext())){
			RequestContext.curr.get().wirte("error:名字已存在");
		}
	}

}
